home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5261 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: RETURN ();
  5. Date: 9 Feb 1996 12:14:07 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4ffdqf$cad@sparcserver.lrz-muenchen.de>
  9. References: <DMFxxq.7M7@emi.net> <4fe4m7$53m@mercury.dur.ac.uk>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. P D Johnson <P.D.Johnson@durham.ac.uk> writes:
  13.  
  14. >: int Input_data()
  15. >: {
  16. >:   x=5,y=30,z=10    /* These were gotten by asking questions */
  17. >:             /* using printf / scanf/fgets (what ever)  */
  18. >:             /*point is they are gotten by question      */
  19.  
  20. >: return(x,y,z);
  21. >: }
  22.  
  23. >Have you tried reading a book on C? You seem to have a lack of 
  24. >understanding of how variables work in C. You can not even start to write 
  25. >a program to do this until you have sorted out the basics of variables 
  26. >and variable scope. 
  27.  
  28. >In your program you want to return several values. you can not use 
  29. >return(x,y,z) as you cannot write x,y,z = get_input() in main() it makes 
  30. >no sense to a C compiler(you might know what you mean).
  31.  
  32. Have _you_ tried reading a book on C? You seem to have a lack of
  33. understanding of how _expressions_work in C.
  34.  
  35. You can write
  36.  
  37.    {
  38.    int x, y, z, get_input();
  39.  
  40.    x, y, z = get_input(); 
  41.    }
  42.  
  43. in main(), and in most other C functions, and it makes a lot of sense 
  44. to a C compiler. In fact, it is a valid expression. It may not do 
  45. what the original poster wants to do, but stating that it is not C
  46. is plain wrong.
  47.  
  48. Kurt
  49. --
  50. | Kurt Watzka                             Phone : +49-89-2180-6254
  51. | watzka@stat.uni-muenchen.de
  52. | ua302aa@sunmail.lrz-muenchen.de
  53.